package com.wakala.employment.adapter.jobCategory;

import android.os.Parcel;
import android.os.Parcelable;

import java.util.ArrayList;
import java.util.List;

public class JobCategoryTreeVo implements Parcelable {
    private Integer id;

    /**
     * 父级ID
     */
    private Integer pid;

    /**
     * 路径
     */
    private String path;

    /**
     * 工种分类名称
     */
    private String name;

    private Integer type;
    private String url;

    private String extra;

    private Boolean status;

    /**
     * 排序
     */
    private Integer sort;

    private List<JobCategoryTreeVo> child = new ArrayList<>();

    protected JobCategoryTreeVo(Parcel in) {
        if (in.readByte() == 0) {
            id = null;
        } else {
            id = in.readInt();
        }
        if (in.readByte() == 0) {
            pid = null;
        } else {
            pid = in.readInt();
        }
        path = in.readString();
        name = in.readString();
        if (in.readByte() == 0) {
            type = null;
        } else {
            type = in.readInt();
        }
        url = in.readString();
        extra = in.readString();
        byte tmpStatus = in.readByte();
        status = tmpStatus == 0 ? null : tmpStatus == 1;
        if (in.readByte() == 0) {
            sort = null;
        } else {
            sort = in.readInt();
        }
        child = in.createTypedArrayList(JobCategoryTreeVo.CREATOR);
    }

    public static final Creator<JobCategoryTreeVo> CREATOR = new Creator<JobCategoryTreeVo>() {
        @Override
        public JobCategoryTreeVo createFromParcel(Parcel in) {
            return new JobCategoryTreeVo(in);
        }

        @Override
        public JobCategoryTreeVo[] newArray(int size) {
            return new JobCategoryTreeVo[size];
        }
    };

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Integer getPid() {
        return pid;
    }

    public void setPid(Integer pid) {
        this.pid = pid;
    }

    public String getPath() {
        return path;
    }

    public void setPath(String path) {
        this.path = path;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getType() {
        return type;
    }

    public void setType(Integer type) {
        this.type = type;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getExtra() {
        return extra;
    }

    public void setExtra(String extra) {
        this.extra = extra;
    }

    public Boolean getStatus() {
        return status;
    }

    public void setStatus(Boolean status) {
        this.status = status;
    }

    public Integer getSort() {
        return sort;
    }

    public void setSort(Integer sort) {
        this.sort = sort;
    }

    public List<JobCategoryTreeVo> getChild() {
        return child;
    }

    public void setChild(List<JobCategoryTreeVo> child) {
        this.child = child;
    }

    @Override
    public String toString() {
        return name;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        if (id == null) {
            dest.writeByte((byte) 0);
        } else {
            dest.writeByte((byte) 1);
            dest.writeInt(id);
        }
        if (pid == null) {
            dest.writeByte((byte) 0);
        } else {
            dest.writeByte((byte) 1);
            dest.writeInt(pid);
        }
        dest.writeString(path);
        dest.writeString(name);
        if (type == null) {
            dest.writeByte((byte) 0);
        } else {
            dest.writeByte((byte) 1);
            dest.writeInt(type);
        }
        dest.writeString(url);
        dest.writeString(extra);
        dest.writeByte((byte) (status == null ? 0 : status ? 1 : 2));
        if (sort == null) {
            dest.writeByte((byte) 0);
        } else {
            dest.writeByte((byte) 1);
            dest.writeInt(sort);
        }
        dest.writeTypedList(child);
    }
}
